/**
 * Created by KhoaNam on 7/12/2014.
 */

var MyButton = MySprite.extend({
    ctor: function(dataSrc){
        this._super();
        this.src = {};
        if(dataSrc.NORMAL){
            this.src.normal = dataSrc.NORMAL;
            this.initWithFile(dataSrc.NORMAL);
        }
        if(dataSrc.DOWN){
            this.src.down = dataSrc.DOWN;
        }
    },

    init: function(){
        this._super();
        this.setSource(this.src.normal);
    },

    setSource: function(src){
        var texture = cc.TextureCache.getInstance().textureForKey(src);
        this.setTexture(texture);
    },

    onTouchBegan: function(touch, event){
        this._super(touch, event);
        this.setSource(this.src.down);
    },

    onTouchEnded: function(touch, event){
        this._super(touch, event);
        this.setSource(this.src.normal);
    }
});